import type { DeepPartial, MenuInfo } from '@/types'

/**
 * ! 已经启用，通过应用管理进行配置
 * @deprecated
 */
export const permissionRoutes: DeepPartial<MenuInfo>[] = [
  {
    menuAddress: '/home',
    identifying: 'Home',
    menuName: '首页',
  },
  {
    menuAddress: '/system-management',
    menuName: '系统管理',
    children: [
      {
        menuAddress: '/enterprise-information',
        identifying: 'EnterpriseInformation',
        menuName: '企业基础信息',
      },
      {
        menuAddress: '/user-management',
        identifying: 'UserManagement',
        menuName: '用户管理',
      },
      {
        menuAddress: '/role-management',
        identifying: 'RoleManagement',
        menuName: '角色管理',
      },
      {
        menuAddress: '/menu-management',
        identifying: 'MenuManagement',
        menuName: '菜单管理',
      },
      {
        menuAddress: '/application-management',
        identifying: 'ApplicationManagement',
        menuName: '应用管理',
      },
      {
        menuAddress: '/dictionary-management',
        identifying: 'DictionaryManagement',
        menuName: '字典管理',
      },
      {
        menuAddress: '/log-management',
        identifying: 'LogManagement',
        menuName: '日志管理',
      },
      {
        menuAddress: '/department-management',
        identifying: 'DepartmentManagement',
        menuName: '部门管理',
      },
      {
        menuAddress: '/energy-conversion-coefficient',
        identifying: 'EnergConversionCoefficient',
        menuName: '能源折标系数',
      },
      {
        menuAddress: '/energy-function-list',
        identifying: 'EnergyFunctionList',
        menuName: '能源种类菜单管理',
        isHidden: 1,
      },
    ],
  },
  {
    menuName: '能管办公管理',
    menuAddress: '/can-manage-office-management',
    children: [
      {
        menuName: '能源管理部门架构管理',
        identifying: 'EnergySectorArchitecture',
        menuAddress: '/energy-sector-architecture',
      },
      {
        menuName: '能耗数据审核',
        identifying: 'EnergyConsumptionReview',
        menuAddress: '/energy-consumption-review',
      },
      {
        menuName: '能耗数据上报',
        identifying: 'EnergyConsumptionReport',
        menuAddress: '/energy-consumption-report',
      },
      {
        menuName: '能耗数据报表查询',
        identifying: 'EnergyConsumptionQuery',
        menuAddress: '/energy-consumption-query',
      },
      {
        menuName: '能源KPI考核管理',
        identifying: 'EnergyKPIAssessment',
        menuAddress: '/energy-kpi-assessment',
      },
      {
        menuName: '班组管理',
        identifying: 'TeamManagement',
        menuAddress: '/team-management',
      },
    ],
  },
  {
    menuAddress: '/basic-data',
    menuName: '基础数据',
    isHidden: 1,
    children: [
      {
        menuAddress: '/basic-data/enterprise-information',
        menuName: '企业信息',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/basic-data/key-energy-consuming-equipment',
        menuName: '重点能耗设备',
        isHidden: 1,
        children: null,
      },
      // {
      //   menuAddress: '/basic-information-management/enterprise-processes',
      //   menuName: '企业工序设置',
      //   children: null
      // },
      // {
      //   menuAddress: '/basic-information-management/process-unit',
      //   menuName: '工序单元设置',
      //   children: null
      // },
      {
        menuAddress: '/basic-data/data-maintenance',
        menuName: '上报数据项维护',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/basic-data/limiting-value',
        menuName: '限值设置',
        isHidden: 1,
        children: null,
      },
    ],
  },
  {
    menuAddress: '',
    menuName: '统计分析',
    isHidden: 1,
    children: [],
  },
  {
    menuAddress: '/report-center',
    menuName: '报表中心',
    isHidden: 1,
    children: [
      {
        menuAddress: '/report-center/energy-consuming-unit',
        menuName: '用能单元能耗统计',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/report-center/energy-consumption',
        menuName: '能耗量统计表',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/report-center/energy-use',
        menuName: '能源用途统计表',
        isHidden: 1,
        children: null,
      },
    ],
  },
  {
    menuAddress: '/data-viewing',
    menuName: '数据查看',
    isHidden: 1,
    children: [
      {
        menuAddress: '/data-viewing/day',
        menuName: '日数据查询',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/data-viewing/month',
        menuName: '月数据查询',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/data-viewing/year',
        menuName: '年数据查询',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/data-viewing/real-time',
        menuName: '实时数据查询',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/data-viewing/real-time-energy-consumption',
        menuName: '实时能耗数据查看',
        isHidden: 1,
        children: null,
      },
    ],
  },
  {
    menuAddress: '/report-data-filling',
    menuName: '上报数据项填报',
    isHidden: 1,
    children: [
      {
        menuAddress: '/report-data-filling/day',
        menuName: '日上报数据填报',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/report-data-filling/month',
        menuName: '月上报数据填报',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/report-data-filling/year',
        menuName: '年上报数据填报',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/report-data-filling/conversion-coefficient',
        menuName: '折标系数填报',
        isHidden: 1,
        children: null,
      },
    ],
  },
  {
    menuAddress: '/data-statistics',
    menuName: '数据统计',
    isHidden: 1,
    children: [
      {
        menuAddress: '/data-statistics/daily-report',
        menuName: '日上报数据统计',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/data-statistics/monthly-report',
        menuName: '月上报数据统计',
        isHidden: 1,
        children: null,
      },
      {
        menuAddress: '/annual-report',
        menuType: 3,
        menuName: '年上报数据统计',
        identifying: 'annual-report',
        isHidden: 1,
        children: null,
      },
    ],
  },
  {
    menuAddress: '/measuring-instruments',
    menuName: '计量器具台账',
    identifying: 'MeasuringInstruments',
    children: null,
  },
  {
    menuAddress: '/warning-informations',
    menuName: '告警信息',
    identifying: 'WarningInformations',
    children: null,
  },
  {
    menuAddress: '/indicator-tree-diagram',
    menuName: '指标管理',
    identifying: 'IndicatorTreeDiagram',
    children: null,
  },
  {
    menuAddress: '/monitoring-points-dataset',
    menuName: '指标数据',
    identifying: 'MonitoringPointsDataset',
    children: null,
  },
  {
    menuAddress: '/indicator-curve-graph',
    menuName: '指标曲线',
    identifying: 'IndicatorCurveGraph',
    children: null,
    isHidden: 1,
  },
  {
    menuAddress: '/energy-consumption-data-summary',
    menuName: '能耗数据汇总',
    identifying: 'EnergyConsumptionDataSummary',
    children: null,
  },
  {
    menuAddress: '/quarterly-reports',
    menuName: '季度报表填报',
    identifying: 'QuarterlyReports',
    children: null,
  },
  {
    menuAddress: '/energy-metering-review',
    menuName: '能源计量审查',
    identifying: 'EnergyMeteringReview',
    children: null,
  },
]

export function handleMenu() {
  const arr: DeepPartial<MenuInfo>[] = []
  let id = 1
  const func = (data: DeepPartial<MenuInfo>[], parentId?: number) => {
    data.forEach((item) => {
      const n: DeepPartial<MenuInfo> = {
        id: id++,
        menuName: '',
        menuType: 2,
        parentId,
        menuAddress: '',
        menuIcon: '',
        menuEnable: 1,
        applicationId: '',
        menuTitle: '',
        isFullscreen: 0,
        isHidden: 0,
        identifying: '',
        redirect: '',
        ...item,
      }
      Reflect.deleteProperty(n, 'children')
      arr.push(n)
      if (item.redirect) {
        n.menuType = 3
      }
      if (item.children && item.children.length > 0) {
        n.menuType = 1
        func(item.children as DeepPartial<MenuInfo>[], n.id!)
      }
    })
  }
  func(permissionRoutes, 0)
  console.warn(123456, arr)
  return arr
}
